{% extends "blogs/admin/base_blog.html" %}

{% block current_action %}Manage comments{% endblock %}

{% block content %}
    
    {% if comments %}
        <p>Here are the comments for this blog. Use the navigation to view earlier/later comments.</p>
        <form action="delete/" method="post">
            <table>
                <thead>
                    <tr>
                        <th><input type="checkbox" name="select_all" onclick="selectAll();" /></th>
                        <th>Date</th>
                        <th>Post</th>
                        <th>Name</th>
                        <th>E-mail</th>
                        <th>Message</th>
                        <th>IP Address</th>
                        <th colspan="2">Action</th>
                    </tr>
                </thead>
                <tbody>
                    {% for comment in comments %}
                        <tr>
                            <td><input type="checkbox" name="selected_comment" value="{{ comment.pk }}" />
                            <td>{{ comment.date }}</td>
                            <td>{{ comment.post }}</td>
                            <td>{{ comment.name }}</td>
                            <td>{{ comment.email }}</td>
                            <td>{{ comment.message|truncatewords_html:50|striptags }}</td>
                            <td><a href="{% url blogs.admin.ban_ip blog_slug %}?ip={{ comment.ip }}" title="Ban this IP"><img src="{{ ADMIN_MEDIA_PREFIX }}img/admin/icon-no.gif" alt="ban IP" /></a> {{ comment.ip }}</td>
                            <td><a href="{% url blogs.admin.comment_edit blog_slug,comment.id %}" title="Edit comment"><img src="{{ ADMIN_MEDIA_PREFIX }}img/admin/icon_changelink.gif" alt="edit" /></a></td>
                            <td><a href="{% url blogs.admin.comment_delete blog_slug,comment.id %}" title="Delete comment"><img src="{{ ADMIN_MEDIA_PREFIX }}img/admin/icon_deletelink.gif" alt="delete" /></a></td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table><br />
            <input type="submit" value="Delete Selected" />
        </form>
        
        {% include 'blogs/admin/comments_nav.html' %}
    {% else %}

        <p>There are no comments to manage for this blog.</p>
    
    {% endif %}
    
    <script type="text/javascript">
    function selectAll() {
        if ($($("input[name=select_all]")[0]).attr("checked")) {
            $("input[name=selected_comment]").each(function() {
                $(this).attr("checked", true);
            });
        } else {
            $("input[name=selected_comment]").each(function() {
                $(this).attr("checked", false);
            });
        }
    }
    </script>

{% endblock %}
